package com.oglvip.business.web.controller;

import com.oglvip.business.dto.ApplyInfoFormDto;
import com.oglvip.business.dto.ResponseData;
import com.oglvip.business.remote.service.api.StoreService;
import com.oglvip.business.remote.service.entity.StoreAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther hanchao
 * @date 2016/12/12 23:18
 */
@RestController
@RequestMapping("/apply")
public class ApplyController {
    @Autowired
    private StoreService storeService;

    @RequestMapping("/save")
    public ResponseData apply(ApplyInfoFormDto info){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        StoreAccount account = (StoreAccount) authentication.getPrincipal();
        info.setTicket(account.getTicket());
        return storeService.apply(info);
    }

}
